#include "hash_table.h"
#include "access.h"

#include <string.h>
#include <stdio.h>

void * _connect(const char * key)
{
    return malloc(1);
}

void _close(void * conn)
{
    free(conn);
}


int main(int argc, char * argv[])
{
    Access * acc = access_create(_connect, _close, 3);

    //获取一个连接
    void * c1 = access_get(acc, "1");
    void * c2 = access_get(acc, "1");
    void * c3 = access_get(acc, "1");
    void * c4 = access_get(acc, "1");
    printf("%p %p %p %p\n",  c1, c2, c3, c4);

    access_release(acc, "1", c2);
    access_release(acc, "1", c1);
    access_release(acc, "1", c3);
    access_release(acc, "1", c4);

    c1 = access_get(acc, "1");
    c2 = access_get(acc, "2");
    c3 = access_get(acc, "2");
    c4 = access_get(acc, "2");

    printf("%p %p %p %p\n",  c1, c2, c3, c4);

    access_release(acc, "2", c2);
    access_release(acc, "1", c1);
    access_release(acc, "2", c3);
    access_release(acc, "2", c4);

    access_destory(acc);

    return 0;
}
